cmake_minimum_required(VERSION 3.22)

# # 设置MT/MTd 时需要设置 CMP0091 政策 需要在project前设置
# if(POLICY CMP0091)
#   cmake_policy(SET CMP0091 NEW)
# endif()

project(SuperControl)

if(MSVC)
    # 设置全局的Debug和Release编译选项
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(USETCP "使用TCP协议" ON)
option(USEUDP "使用UDP协议" OFF)
option(USEICMP "使用ICMP协议" OFF)

add_subdirectory(Utils)
add_subdirectory(Protocol)
add_subdirectory(Logic)
add_subdirectory(Publicfunc)

add_executable(mainExe main.cpp)

#设置MT/MTd 方法1
if (MSVC)
    target_compile_options(mainExe PRIVATE $<$<CONFIG:Release>:/MT> $<$<CONFIG:MinSizeRel>:/MT> $<$<CONFIG:RelWithDebInfo>:/MT> $<$<CONFIG:Debug>:/MTd>)
endif()
# #设置MT/MTd 方法2 前面需要设置CMP0091
# if (MSVC)
# set_property(TARGET mainExe PROPERTY
#   MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# endif()

# 将头文件目录添加到库目标
target_include_directories(mainExe PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
#链接子目录中的库
target_link_libraries(mainExe PRIVATE UtilsLib ProtocolLib LogicLib PbFuncLib)